#include "glare.core.ShaderInputDeclaration.h"

namespace Glare {

	ShaderInputElement::ShaderInputElement() 
		: SemanticName("")
		, SemanticIndex(0)
		, Format(PF_UNKNOWN)
		, InputSlot(0)
		, Offset(0)
		, InstanceElement(false)
		, InstanceFrequency(0)
	{

	}

	ShaderInputDeclaration::ShaderInputDeclaration() 
		: _total_size(0)
	{
	}

	const uint& ShaderInputDeclaration::GetTotalSize()
	{
		// TODO: recalculate total size on "Build"
		if (!_total_size)
		{
			ElementList::iterator it = InputElements.begin();
			ElementList::iterator end = InputElements.end();

			while (it != end)
			{
				// TODO: remove Ogre PixelFormat related stuff and add own utils
				switch ((*it).Format)
				{
				case PF_R32G32_FLOAT: _total_size += 8; break;
				case PF_R32G32B32_FLOAT: _total_size += 12; break;
				default: (void)0;
				}

				++it;
			}
		}

		return _total_size;
	}
}